/*
 * TCCC03 Round 2 Prob 2
 */

import java.util.*;
import java.util.regex.*;
import java.text.*;
import java.math.*;


public class Marketing
{


    public long howMany(String[] compete)
    {
	int n = compete.length;
	ArrayList<ArrayList<Integer>> adjlist = new ArrayList<ArrayList<Integer>> ();
	for (int i = 0; i < n; ++i)
	    adjlist.add (new ArrayList<Integer> ());
	for (int i = 0; i < compete.length; ++i) {
	    String[] tmp = compete[i].split (" ");
	    if (tmp == null)
		continue;
	    
	    for (String tmps:tmp) {
		if (tmps.length () == 0)
		    continue;
		int j = Integer.parseInt (tmps);
		adjlist.get (i).add (j);
		adjlist.get (j).add (i);
	    }
	}
	boolean[] visited = new boolean[n];
	
	ArrayList<Integer> ans = new ArrayList<Integer> ();
	for (int i = 0; i < n; ++i) {
	    if (!visited[i]) {
		int sum = 0;
		LinkedList<Integer> queue = new LinkedList<Integer> ();
		int[] level = new int[n];
		queue.add (i);
		visited[i] = true;
		++sum;
		while (!queue.isEmpty ()) {
		    int q = queue.removeFirst (), l = level[q];
		    for (int next:adjlist.get (q)) {
			if (visited[next]) {
			    if ((l+1+level[next])%2 != 0)
				return -1;
			} else {
			    level[next] = l + 1;
			    queue.addLast (next);
			    visited[next] = true;
			    ++sum;
			}
		    }
		}
		ans.add (sum);
	    }
	}
	
	return 1L<<ans.size ();
    }
    

}
//Powered by KawigiEdit 2.1.4 (beta) modified by pivanof!